<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>新增地址</title>
    <!--bootstrap-->
    <link href="/shop-app/bootstrap/css/bootstrap.min.css" rel="stylesheet">
    <!-- jQuery (Bootstrap 的所有 JavaScript 插件都依赖 jQuery，所以必须放在前边) -->
    <script src="/shop-app/js/jquery.min.js"></script>
    <!-- 加载 Bootstrap 的所有 JavaScript 插件。你也可以根据需要只加载单个插件。 -->
    <script src="/shop-app/bootstrap/js/bootstrap.min.js"></script>
    <!-- 引入HttpUtil.js -->
    <script src="/shop-app/js/HttpUtil.js"></script>
    <!--引入存到浏览器的js文件-->
    <script src="/shop-app/js/UserCacheUtil.js"></script>
    <!-- 界面报icon找不到问题 -->
    <link rel="shortcut icon" href="#"/>
</head>
<body>


<!--导入页面公共头部-->
<div class="Top_header"></div>


<div class="container">
    <div class="row">
        <div class="col-md-8 col-md-offset-2  col-lg-8 col-lg-offset-2" style="margin-top: 50px">
            <div class="alert btn-info text-center" role="alert" style="font-size: 30px">添加地址
            </div>
        </div>
    </div>
</div>


<!-- 账号密码验证 -->
<div class="container" id="div-hide-by-password">
    <div class="row">
        <div class="col-md-8 col-md-offset-2  col-lg-8 col-lg-offset-2 ">
            <form class="form-horizontal">

                <button onclick="ToAddressManager()" type="button" class="btn btn-default btn btn-info"
                        style="width: 120px">返回地址管理
                </button>

                <div class="form-group">
                    <label class="col-sm-3 ol-lg-3 control-label">姓名</label>
                    <div class="col-sm-7 col-lg-7">
                        <input  type="text" class="form-control aName" placeholder="userName">
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-3 ol-lg-3 control-label">电话</label>
                    <div class="col-sm-7 col-lg-7">
                        <input  type="text" class="form-control aTel" placeholder="phone">
                    </div>
                </div>

                <div class="form-group">
                    <label class="col-sm-3 control-label">地址</label>
                    <div class="col-sm-7">
                        <textarea class="form-control aDetail" rows="3"></textarea>
                    </div>
                </div>
                <div class="form-group">
                    <div class="col-sm-offset-2  col-sm-12">
                        <button onclick="addAddress()" type="button" class="btn btn-default btn btn-info"
                                style="width: 120px">确认
                        </button>
                        <button type="reset" class="btn btn-default col-sm-offset-3 btn btn-warning"
                                style="width: 120px">重置
                        </button>
                    </div>
                </div>

            </form>
        </div>
    </div>
</div>

<script>
    //加载公有头部
    $(".Top_header").load("/shop-app/include/header.html");

    let loginUser = getLocalStorage("loginUser");
    console.log(loginUser);

    //确认添加按钮
    function addAddress() {
        let url = "/address/insertAddressPost";
        let params = {
            uId: loginUser.uId,
            aName: $(".aName").val(),
            aTel: $(".aTel").val(),
            aDetail: $(".aDetail").val(),
        };
        console.log(params);

        httpPostApi(url, params, function (data) {
            alert(data)
            window.location.href = "/shop-app/address/address.html";
        });
    }

    function ToAddressManager() {
        window.location.href="/shop-app/address/address.html"
    }

</script>

</body>
</html>